package com.panda.game.xls.screen;

import com.panda.game.xls.component.MyJLabel;
import com.panda.game.xls.component.MyJTextArea;
import com.panda.game.xls.constant.ScreenConstant;

import javax.swing.*;
import java.awt.*;

public class ToolFrame extends JFrame {

    private static MyJTextArea output;

    public ToolFrame() {
        setTitle("游戏文档小工具");//设置显示窗口标题
        setSize(ScreenConstant.SCREEN_WIDTH, ScreenConstant.SCREEN_HEIGHT);//设置窗口显示尺寸
        setLayout(new BorderLayout(5, 5));//间距大小
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//置窗口是否可以关闭

        initCompent();//初始化组件内容

        setLocationRelativeTo(null);//居中显示
        setVisible(true);//设置窗口是否可见
    }

    public void initCompent() {
        initLeft();
        initCenter();
    }

    public void initLeft() {
        JPanel jp = new TabScreen();
        add(jp, BorderLayout.WEST);
    }

    public void initCenter() {
        JPanel jp = new JPanel();
        jp.setPreferredSize(new Dimension(ScreenConstant.SCREEN_WIDTH_HALF, 0));
        MyJLabel jl = new MyJLabel("输出: ");
        jp.add(jl);

        output = new MyJTextArea("", 13, 30);
        JScrollPane jsp = new JScrollPane(output);//将文本域放入滚动窗口
        jp.add(jsp);//将JScrollPane添加到JPanel容器中

        add(jp, BorderLayout.CENTER);
    }

    public static void setOutput(String info){
        output.setText(info);
    }

}
